// Inserts text dynamically in the document when it is called
function sayHello ()
{
if(getHourOfDay()<5 || getHourOfDay()>19)
document.write('<FONT COLOR="FFFF00"> a good night!</FONT>');
else
{
if ( getHourOfDay() <11)
{
document.write('<FONT COLOR="52A553"> a good morning!</FONT>');
}
else
{
document.write('<FONT COLOR="ED363C"> a good day!</FONT>');
}
}
}
// -- End of JavaScript code -------------- -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR=FFFFFF TEXT=000000>
<H1>JavaScript Dynamic Document</H1>
<B>This stationery page contains JavaScript that creates a dynamic page</B>
<P>
Please note that JavaScript is currently only available in Netscape Navigator 2.0 or higher. <BR>
<FONT COLOR="931B15">Do not assume that all in your audience are using a JavaScript enabled browser.</FONT>
<HR>
Here is an example on how JavaScript can be used to provide a dynamic page that will change its contents depending upon the local time specified in the browser's system and the OS that is used by the reader.
'<P><FONT COLOR="385FD1">Very, very nice to see that you are using MacOS!</FONT>');
else
document.write(
'<P>Sad too see that you are not using a Mac to view this page.')
// -->
</SCRIPT>
<HR>
<P>
<B>How to use:</B><BR>
Several small scripts are embedded inside the text contents of this file. The scripts are executed - and inserts text - when the page are loaded.
<P>
Replace the contents inside the script with calls to your own test functions and add text you want to have displayed inside <FONT COLOR="FF3366"><CODE>document.write()</CODE></FONT> function inside the script. It is recommended to create functions for complex scripts and place these in the HEAD section, see the <TT>sayHello</TT> function for an axample of this.
<P>
Edit this page or copy selected scripts to create your own dynamic page!
<P>
<HR>
<P>
<B>Example code for the first dynamic text above:</B>
<XMP>Welcome <B><SCRIPT>
<!--
document.write(navigator.userAgent)
// -->
</SCRIPT></B>!</XMP>
You <I>may</I> also write the script without the <FONT COLOR="555555"><!--</FONT> comment (see below), but if you do this the actual script may show up in a browser that doesn't support JavaScript.